/* ===== max flow ===== */

vector <bool> used;
oint Q = 1 << 30;

bool dfs(int point, vector <vector <int> >& g, int& finish)
{
	if (point == finish)
		return true;
	if (used[point])
		return false;

	used[point] = true;
	forx(loop, g.size())
	{
		if (g[point][loop] >= Q && dfs(loop, g, finish))
		{
			g[point][loop] -= Q;
			g[loop][point] += Q;
			return true;
		}
	}

	return false;
}

oint maxflow(vector <vector <int> >& g, int start, int finish)
{
	oint answer = 0;
	used.resize(g.size(), false);

	while (Q > 0)
	{
		used.assign(used.size(), false);
		while (dfs(start, g, finish))
		{
			used.assign(used.size(), false);
			answer += Q;
		}
		Q /= 2;
	}

	return answer;
}

/* ----- max flow ----- */